{%- if yandex_pixels -%}
  <!-- Yandex.Metrika counter -->
  <script type="text/javascript">
        (function(m,e,t,r,i,k,a){m[i]=m[i]||function(){(m[i].a=m[i].a||[]).push(arguments)};
        m[i].l=1*new Date();
        for (var j = 0; j < document.scripts.length; j++) {if (document.scripts[j].src === r) { return; }}
        k=e.createElement(t),a=e.getElementsByTagName(t)[0],k.async=1,k.src=r,a.parentNode.insertBefore(k,a)})
        (window, document, "script", "https://mc.yandex.ru/metrika/tag.js", "ym");

    {% for pixid in yandex_pixels %}
      ym("{{pixid}}", "init", {
        clickmap:true,
        trackLinks:true,
        accurateTrackBounce:true
      });
    {% endfor %}

    {% for pixid in yandex_pixels %}
        ym('{{pixid}}','reachGoal','PageView')
    {% endfor %}

    {%- if template == 'product_detail' -%}
      {% for pixid in yandex_pixels %}
          ym('{{pixid}}','reachGoal','ViewContent')
      {% endfor %}
    {%- endif -%}



      {%- if template == 'search_detail' and search.keywords -%}
        {% for pixid in yandex_pixels %}
          ym('{{pixid}}','reachGoal','Search')
        {% endfor %}
      {%- endif -%}


      {%- if controller == 'order' and action == 'success' -%}
        {% capture yandex_pixels_order_id %}yandex_pixels_{{order.id}}{% endcapture %}
        {% get_cache key={yandex_pixels_order_id} var_name=yandex_pixels_status%}
        {% if yandex_pixels_status ==0 %}
          {% for pixid in yandex_pixels %}
            ym('{{pixid}}','reachGoal','Purchase')
          {% endfor %}
        {% endif %}
      {%- endif -%}



      {%- if template == 'order_contact_information' or template == 'orderonepage_index' -%}
        {% for pixid in yandex_pixels %}
          ym('{{pixid}}','reachGoal','InitiateCheckout')
        {% endfor %}
      {%- endif -%}


  </script>
  <noscript>
    <div><img src="https://mc.yandex.ru/watch/94340395" style="position:absolute; left:-9999px;" alt=""></div>
  </noscript>

  <script type="text/javascript">
    function callback_yandex_add_to_cart(ecdata) {
      {% for pixid in yandex_pixels %}
        ym('{{pixid}}','reachGoal','AddToCart')
      {% endfor %}
    }

    function callback_yandex_generate_lead() {

    }

    function callback_yandex_share_product(ec_data, platform) {}

    function callback_yandex_begin_checkout() {}

    function callback_yandex_login() {}

    function callback_yandex_remove_from_cart(ecdata) {}

    function callback_yandex_add_address_information() {}

    function callback_yandex_add_shipping_information() {}

    function callback_yandex_add_payment_information() {}

    function callback_yandex_to_wishlist() {
      {% for pixid in yandex_pixels %}
        ym('{{pixid}}','reachGoal','AddToWishlist')
      {% endfor %}
    }

    function callback_yandex_sign_up() {
      {% for pixid in yandex_pixels %}
        ym('{{pixid}}','reachGoal','CompleteRegistration')
      {% endfor %}
    }
  </script>
{%- endif -%}
